cmake_minimum_required(VERSION 2.8.3)
project(dispatch_server)


add_compile_options(-std=c++11)

SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
SET(CMAKE_BUILD_TYPE Release)
# SET(CMAKE_BUILD_TYPE Debug)

find_package(catkin REQUIRED COMPONENTS
  dispatch_system
  moying_comm_lib
  commu_with_sm
  dispatch_system_ros_viz
)


######### catkin ###########
catkin_package(
  INCLUDE_DIRS include
  LIBRARIES dispatch_server
  CATKIN_DEPENDS dispatch_system moying_comm_lib commu_with_sm dispatch_system_ros_viz
  DEPENDS system_lib
)
######### catkin ###########



######### Build ###########
include_directories(
  include
  ${catkin_INCLUDE_DIRS}
) 

add_library(${PROJECT_NAME}
  src/dispatch_server.cpp
  src/const_nav_path.cpp
  src/vehicle_monitor.cpp
  src/revise_vehicle_path.cpp

)
target_link_libraries(${PROJECT_NAME}
   ${catkin_LIBRARIES}
   libconfig++.so
)

  
add_executable(${PROJECT_NAME}_node 
  src/main.cpp  
  src/deadlock_handler.cpp
)

#set_target_properties(${PROJECT_NAME}_node PROPERTIES
#  RUNTIME_OUTPUT_DIRECTORY "${commu_with_sm_SOURCE_DIR}/../config")

target_link_libraries(${PROJECT_NAME}_node
  ${catkin_LIBRARIES}
  ${PROJECT_NAME}
  libconfig++.so
)

#配置包含的头文件（安装后可在/opt/ros/kinetic/include/${PROJECT_NAME}路径下找到该头文件）
install(DIRECTORY include/${PROJECT_NAME}/

  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}

)

## Mark executables and/or libraries for installation
install(TARGETS ${PROJECT_NAME} 
   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)

## Mark executables and/or libraries for installation
 install(TARGETS ${PROJECT_NAME}_node 
   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
 )